﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<brjostagjof.Models.Article>>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Greinar
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <% if (Page.User.IsInRole("Administrators") || Page.User.IsInRole("Specialists"))
       { %>
    <a href="/Home/AddArticle/" class="linksWhite"> Ný grein </a>
        <%} %>
          <% if (Page.User.IsInRole("Administrators"))
             { %>
    <a href="/Home/AddArticleCategory/" class="linksWhite"> Nýr greinaflokkur </a>
    <% } %>
    <a href="/Home/Index/" class="linksWhite">Til baka á forsíðu</a>
    <h2>Greinaflokkar:</h2>
        <ul>
        <% var categories = brjostagjof.Controllers.HomeController.GetArticleCategories();
        foreach (var category in categories)
        { %>
            <li>
            <a href="/Home/GetArticleByCategoryID/<%: category.ID %>"><%: category.name%></a>
            </li>
        <% } %>
        </ul>

        <h2>Nýjustu greinar:</h2>

        <% var latestArticles = brjostagjof.Controllers.HomeController.Get10Articles();
        foreach (var item in latestArticles)
        { 
            int count = brjostagjof.Controllers.HomeController.GetCommentsCountByArticleBaseID(item.articleBaseID); %>
        <div class="entry">
        <div class="entry-bgtop">
        <div class="entry-bgbtm">
            <h2 class="title"><a href="<%: item.ArticleBase.link %><%: item.articleBaseID %>"><%: item.ArticleBase.InformationBase.headline%></a></h2>
            <p class="meta">Höfundur: <a href="../../MySite/ViewUserByID/<%:item.ArticleBase.User.ID  %>"><%: item.ArticleBase.User.name%></a>, <%: item.ArticleBase.InformationBase.date%> &nbsp;&bull;&nbsp; 
                Umsagnir  (<%: count %>) &nbsp;&bull;&nbsp; 
            <a href="/Home/GetArticleByCategoryID/<%: item.ArticleBase.ArticleCategory.ID %>" class="permalink"> <%: item.ArticleBase.ArticleCategory.name %></a> 
            &nbsp;&bull;&nbsp; 
            <a href="<%: item.ArticleBase.link %><%: item.articleBaseID %>" class="permalink">Öll grein</a></p> 
        </div>
        </div>
        </div>
        <% } %>


            <% int page = 1; %>
            <% for (int i = page-4; i < page+5; i++)
            {%>
                <% if(i == 0)
                   { %>
                   <a class="colorMeBlack" href="/Home/Greinar/">1</a>
                   <% }%>
                 <% if ((i > 0) && (i <= (((brjostagjof.Controllers.HomeController.GetAllArticleCount())/5)-1)))
                { %>
                      <a href="/Home/Get10ArticleByPageID/<%: i %>"><%: i + 1%></a>

               <% }%>
           <% } %>
           <a href="/Home/Get10ArticleByPageID/1" class="linksWhite">Eldri greinar</a>



</asp:Content>

